package com.matrix.draft.sockettest.mycodec.handler;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ReplayingDecoder;

import java.util.List;

public class MyDecoder extends ReplayingDecoder<Long> {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        // 在ReplayingDecoder可以不用判断字节数, 它自动根据readIndex来做处理 , 我们只需要调用read方法即可.
        out.add(in.readLong());
        System.err.println("decoded successfully");
    }
}
